<?php
session_start();

$host="localhost"; // Host name  
$username="root"; // Mysql username  
$password=""; // Mysql password  
$db_name="laptop"; // Database name  
$tbl_name="nhanvien"; // Table name                                                        
// Connect to server and select databse. 
  mysql_connect("$host", "$username", "$password")or die("cannot connect");  
  mysql_select_db("$db_name")or die("Không thể kết nối đến cơ sở dữ liệu");
  
$username = $_POST['username'];
$password = $_POST['password'];

$sql= "SELECT * FROM nhanvien where Taikhoan='$username' and Matkhau='$password'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$count=mysql_num_rows($result);
	

if($count==1)
{
$_SESSION['Taikhoan'] = $row['Taikhoan'];
$_SESSION['Matkhau'] = $row['Matkhau']; 
$_SESSION['idNhanVien'] = $row['idNhanVien']; 
$_SESSION['TenNhanVien'] = $row['TenNhanVien']; 
$_SESSION['idLoai'] = $row['idLoai']; 

 header("location:index.php");
}
else 
{
    header("location:login.php");
}
?>
